<?php

function getRoute ($points) {
	$lock = array();
	$route = array();
	$check = array();


	foreach ($points as $startKey => $startValue) {
		$from = $points[$startKey]["from"];

		if ($points[$startKey]["start"] == 1) {
			$route[0] = $from;
		}

		foreach ($points[$startKey]["distance"] as $endKey => $distance) {
			$check[$endKey]["to"] = $endKey;
			$check[$endKey]["distance"] = $distance;
		}

		$result = sortDistance($check);

		foreach ($result as $orderKey => $resultValue){
			if (!in_array($result[$orderKey]["to"], $route)) {
				$route[] = $result[$orderKey]["to"];
				break;
			}
		}

		unset($result);
		unset($check);
	}

	return $route;
}

?>